<div class="bg-white">
	<header class="mui-bar mui-bar-nav head-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">企业名录</h1>
	</header>
	<!--DOM -->
	<div class="mui-content bg-white">
		<!-- Swiper -->
		<div class="swiper-container index-banner-swiper">
			<div class="swiper-wrapper">

				@if (ViewBag.Banner != null && (ViewBag.Banner as List<BannerEntity>)?.Count > 0)
					{
					foreach (var item in ViewBag.Banner as List<BannerEntity>)
						{
						<div class="swiper-slide">
							<img class="swiper-lazy" data-src="@item.ImgUrl" />
						</div>
						}
						}
						else
						{

						<div class="swiper-slide">
							<img class="swiper-lazy" data-src="/images/index-banner-img1.jpg" alt="" />
						</div>
						}
			</div>
			<div class="swiper-pagination"></div>
		</div>

		<div class="qj">
			<div class="mui-input-group qj-input-group">
				<div class="mui-input-row">
					<label>公司名称：</label>
					<input type="text" placeholder="请输入公司名称" class="j-company">
				</div>
				<div class="mui-input-row">
					<label>联系电话：</label>
					<input type="text" class="mui-input-clear j-tel" placeholder="请输入联系电话">
				</div>
				<div class="mui-input-row">
					<label>联系人：</label>
					<input type="text" class="mui-input-clear j-lianxiren" placeholder="请输入联系人">
				</div>
				<div class="mui-input-row">
					<label>公司地址：</label>
					<input type="text" class="mui-input-clear j-address" placeholder="请输入地址">
				</div>
				<div class="mui-input-row">
					<label>资源共享区：</label>
					<input type="text" class="mui-input-clear j-area" placeholder="请输入资源共享区">
				</div>
				<div class="mui-input-row">
					<label>公司简介：</label>
					<input type="text" class="mui-input-clear j-jianjie" placeholder="请输入公司简介">
				</div>

				<div class="mui-input-row" style="height: auto;">
					<label>公司实力照：</label>
					<input type="hidden" value="" name="imgs" class="j-imgs">
					<div class="yyzz mui-pull-right mui-text-left j-moimgs">
						<input type="file" class="j-img up-img" accept="image/*" />
					</div>

				</div>


				<div class="mui-input-row" style="height: auto;">
					<label>公司图标：</label>
					<input type="hidden" name="ico" class="j-icourl">
					<div class="yyzz mui-pull-right mui-text-left j-icodiv">
						<input type="file" class="j-ico up-img" accept="image/*" />
					</div>

				</div>


			</div>

			<br />
			<!---->
			<button class="mui-btn mui-btn-block mui-btn-green res-btn">提交</button>
			<br />
		</div>
	</div>
</div>

@section Scripts{
<script type="text/javascript" charset="utf-8">
	//
	var swiper = new Swiper('.swiper-container', {
		slidesPerView: 3,
		speed: 700,
		spaceBetween: 0,
		slidesPerView: 'auto',
		centeredSlides: true,
		loop: true,
		pagination: {
			el: '.swiper-pagination',
			clickable: true,
		},
		//          autoplay: {
		//              delay: 3000,
		//              stopOnLastSlide: false,
		//              disableOnInteraction: false,
		//          },
		lazy: {
			loadPrevNext: true,
			loadOnTransitionStart: false,
			loadPrevNextAmount: 1,
		},
	});

	swiper.lazy.load();

	$(".res-btn").click(function() {

		if ($(".j-company").val().length == 0) {
			//提示
			layerm.open({
				content: '请输入公司名称',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}

		if ($(".j-tel").val().length != 11) {
			//提示
			layerm.open({
				content: '请输入正确的手机号',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}
		if ($(".j-lianxiren").val().length == 0) {
			//提示
			layerm.open({
				content: '请输入联系人',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}
		if ($(".j-area").val().length == 0) {
			//提示
			layerm.open({
				content: '请输入共享区域',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}
		if ($(".j-jianjie").val().length == 0) {
			//提示
			layerm.open({
				content: '请输入公司简介',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}
		if ($(".j-icourl").val().length == 0) {
			//提示
			layerm.open({
				content: '请上传公司图标',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}

		if ($(".j-imgs").val().length == 0) {
			//提示
			layerm.open({
				content: '请上传实力照',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}

		if ($(".j-address").val().length == 0) {
			//提示
			layerm.open({
				content: '请输入公司地址',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}
		if (!isupover) {
			//信息框
			layerm.open({
				content: '请等待图片上传完',
				btn: '好的'
			});
			return false;
		}

		var postdata = {
			name: $(".j-company").val(),
			tel: $(".j-tel").val(),
			contacts: $(".j-lianxiren").val(),
			area: $(".j-area").val(),
			present: $(".j-jianjie").val(),
			ico: $(".j-icourl").val(),
			imgs: $(".j-imgs").val(),
			companyaddress: $(".j-address").val()
		}

		$.ajax({
			type: "post",
			data: postdata,
			url: '@Url.Action("Add")',
			success: function(result) {
				consolt.log(result);
				if (result.State == "OK") {
					//信息框
					layerm.open({
						content: '已成功提交，请等待审核。',
						btn: '好的'
					});
				}
			}
		})

	});



	let isupover = false;
	layui.use(['form', 'upload'], function() {
		var upload = layui.upload;
		//普通图片上传
		var uploadInst = upload.render({
			elem: '.j-img',
			url: '@Url.Action("UploadFilesAjax","Login")',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$(".j-moimgs").before("<img src='" + result + "'>");
				});
			},
			done: function(res) {

				console.log(res);

				let imgs = $('.j-imgs').val();
				if (imgs === "") {
					$('.j-imgs').val(res.data.src);
				} else {
					$('.j-imgs').val(imgs + "," + res.data.src);
				}



				//上传成功
			},
			error: function() {
				//信息框
				layer.open({
					content: '上传失败，请联系我们或者稍后重试',
					btn: '好的'
				});
			}
		});


		var uploadInsts = upload.render({
			elem: '.j-ico',
			url: '@Url.Action("UploadFilesAjax","Login")',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$(".j-icodiv").before("<img src='" + result + "'>");
				});
				$(".j-icodiv").hide();
			},
			done: function(res) {

				$('.j-icourl').val(res.data.src);

				isupover = true;
				//上传成功
			},
			error: function() {
				//信息框
				layer.open({
					content: '上传失败，请联系我们或者稍后重试',
					btn: '好的'
				});
			}
		});


	});
</script>
}
